package com.wanpinghui.wphlibrary.common;

import com.wanpinghui.wphlibrary.model.addrbook.bean.AddrbookBean;
import com.wanpinghui.wphlibrary.model.addrbook.bean.MobileListBean;
import com.wanpinghui.wphlibrary.model.base.bean.AppInfoBean;
import com.wanpinghui.wphlibrary.model.base.bean.ImageBean;
import com.wanpinghui.wphlibrary.model.base.pay.GetWXPayResult;
import com.wanpinghui.wphlibrary.model.business.bean.CommentBean;
import com.wanpinghui.wphlibrary.model.business.bean.DynamicBean;
import com.wanpinghui.wphlibrary.model.business.bean.DynamicPageData;
import com.wanpinghui.wphlibrary.model.business.bean.SaveDynamic;
import com.wanpinghui.wphlibrary.model.business.bean.ThumbUpBean;
import com.wanpinghui.wphlibrary.model.message.bean.GetMsgHistoryResult;
import com.wanpinghui.wphlibrary.model.message.bean.MsgBean;
import com.wanpinghui.wphlibrary.model.message.bean.MsgFileBean;
import com.wanpinghui.wphlibrary.model.message.bean.RecentMsgBean;
import com.wanpinghui.wphlibrary.model.oauth.bean.LoginResponseBean;
import com.wanpinghui.wphlibrary.model.oauth.bean.UserBean;
import com.wanpinghui.wphlibrary.model.oauth.bean.UserInformation;
import com.wanpinghui.wphlibrary.model.object.bean.BidObjectResult;
import com.wanpinghui.wphlibrary.model.object.bean.FeedBackReasonBean;
import com.wanpinghui.wphlibrary.model.object.bean.FeedbackInfoBean;
import com.wanpinghui.wphlibrary.model.object.bean.GetOjbectDetailResult;
import com.wanpinghui.wphlibrary.model.object.bean.GetOjbectListResult;
import com.wanpinghui.wphlibrary.model.object.bean.GetParticipationListResult;
import com.wanpinghui.wphlibrary.model.order.bean.OrderItemBean;
import com.wanpinghui.wphlibrary.model.order.bean.OrderRemarkBean;
import com.wanpinghui.wphlibrary.model.order.bean.PageDataBean;
import com.wanpinghui.wphlibrary.model.order.bean.SingleOrderItem;
import com.wanpinghui.wphlibrary.model.product.bean.CartBean;
import com.wanpinghui.wphlibrary.model.product.bean.OrderCreateParams;
import com.wanpinghui.wphlibrary.model.product.bean.ProductGroupBean;
import com.wanpinghui.wphlibrary.model.product.bean.ProductPageBean;
import com.wanpinghui.wphlibrary.model.user.bean.AreaBean;
import com.wanpinghui.wphlibrary.model.user.bean.AvaterBean;
import com.wanpinghui.wphlibrary.model.user.bean.CompanyBean;
import com.wanpinghui.wphlibrary.model.user.bean.CreditRuleBean;
import com.wanpinghui.wphlibrary.model.user.bean.GetBusinessResult;
import com.wanpinghui.wphlibrary.model.user.bean.GetRechargeResult;
import com.wanpinghui.wphlibrary.photovideo.bean.BaseUrlBean;

import java.util.List;
import java.util.Map;

import okhttp3.RequestBody;
import retrofit.callback.YunShlResult;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;
import rx.Observable;


/***
 * 功能描述:
 * 作者:qiujialiu
 * 时间:2017/11/22
 ***/

public interface    IWPHApi {

    @GET("api/v2/send_captcha")
    Observable<YunShlResult<Object>> sendLoginCaptcha(@Query("mobile") String moblile);

    /**
     * 登录
     * @return
     */
    @POST("api/v2/login")
    Observable<YunShlResult<LoginResponseBean>> login(@Body Map<String, Object> body);

    /**
     * 工程商认证
     * @return
     */
    @POST("api/v2/supplier/certify")
    Observable<YunShlResult<UserBean>> certirySupplier(@Body Map<String, Object> body);

    @GET("api/v2/user")
    Observable<YunShlResult<UserBean>> getUserInfo();

    @GET("api/v2/user/credit_rule")
    Observable<YunShlResult<List<CreditRuleBean>>> credit_rule();

    @PUT("api/v2/user")
    Observable<YunShlResult<UserInformation>> UpdateUserInfo(@Body Map<String, Object> body);

    /**
     * 获取项目列表
     * @param published_at
     * @param city
     * @param business
     * @param demand
     * @param pageSize
     * @return
     */
    @GET("api/v2/demands")
    Observable<YunShlResult<GetOjbectListResult>> getObjectList(@Query("sort_val") Long published_at,
                                                                @Query("city") String city,
                                                                @Query("business") String business,
                                                                @Query("demand") String demand,
                                                                @Query("pagesize") int pageSize);

    /**
     * 获取项目详情
     * @param id
     * @return
     */
    @GET("api/v2/demand/{id}")
    Observable<YunShlResult<GetOjbectDetailResult>> getObjectDetail(@Path("id") long id);

    /**
     * 获取用户参与列表
     * @param demandId
     * @return
     */
    @GET("api/v2/demand/{demandId}/partic")
    Observable<YunShlResult<GetParticipationListResult>> getParticList(@Path("demandId") long demandId);

    /**
     *
     * @param demandId
     * @param body
     * @return
     */
    @POST("api/v2/demand/{demandId}/bid")
    Observable<YunShlResult<BidObjectResult>> bidObject(@Path("demandId") long demandId, @Body Map<String, Object> body);


    @POST("axb/query_call_number")
    Observable<YunShlResult<Object>> callNumber(@Body Map<String,Object> params);

    @POST("api/v2/product/pictures")
    Observable<YunShlResult<ImageBean>> uploadProductFile(@Body RequestBody body);

    /**
     * 申报
     * @param demandId
     * @param body
     * @return
     */
    @POST("api/v2/demand/{demandId}/finish_img")
    Observable<YunShlResult<ImageBean>> objectReport(@Path("demandId") long demandId, @Body Map<String,Object> body);

    /**
     * 反馈失效
     * @param demandId
     * @param body
     * @return
     */
    @POST("api/v2/demand/{id}/feedback")
    Observable<YunShlResult<FeedbackInfoBean>> objectFeedback(@Path("id") long demandId, @Body Map<String, Object> body);



    @GET("api/v2/app/android/versions")
    Observable<YunShlResult<AppInfoBean>> checkAppVersion();


    @PUT("api/v2/user/avatar")
    Observable<YunShlResult<AvaterBean>> avatar(@Body Map<String,Object> body);


    @PUT("api/v2/user/business")
    Observable<YunShlResult<Object>> businessScope(@Body Map<String,Object> body);

    @PUT("api/v2/user/areas")
    Observable<YunShlResult<Object>> areasScope(@Body Map<String,Object> body);

    @POST("api/v2/pay/wx/app")
    Observable<YunShlResult<GetWXPayResult>> buildWXPayParams(@Body Map<String, Object> body);

    @POST("api/v2/pay/wx/app/discount")
    Observable<YunShlResult<GetWXPayResult>> buildWXPayParams2(@Body Map<String, Object> body);

    @GET("api/v2/pack_set")
    Observable<YunShlResult<GetRechargeResult>> getRechargePlansList();

    /**
     * 获取我的服务类型
     */
    @GET("api/v2/user/business")
    Observable<YunShlResult<GetBusinessResult>> getMyBusiness();

    //保存文件
    @POST("api/v2/im/file")
    Observable<YunShlResult<MsgFileBean>> uploadIMFile(@Body RequestBody body);

    //保存IM消息
    @POST("api/v2/im/messages")
    Observable<YunShlResult<String>> saveMessages(@Body Map<String, List<MsgBean>> body);

    @GET("api/v2/im/messages")
    Observable<YunShlResult<GetMsgHistoryResult>> getMsgHistory(@Query("group_id") String groupId,
                                                                @Query("created_at") Long createAt,
                                                                @Query("message_count") int count);
    @GET("api/v2/im/notifies")
    Observable<YunShlResult<List<RecentMsgBean>>> getRecentMsbBeanList();

    //upate un read num
    @PUT("api/v2/im/notifies")
    Observable<YunShlResult<Object>> updateRecentMsbUnReadNum(@Body Map<String,Object> body);

    @GET("api/v2/demand/feedback/types")
    Observable<YunShlResult<List<FeedBackReasonBean>>> getFeedBackTypes();

    /**
     * 分页获取个人订单列表
     * @return
     */
    @GET("/api/v1/mine/orders/searchPersonalList")
    Observable<YunShlResult<PageDataBean<OrderItemBean>>> searchPersonalList(@Query("currentPage") int currentPage,@Query("related_id") int related_id);

    /**
     * 添加订单备注
     * @param body
     * @return
     */
    @POST("/api/v1/mine/orders/addOrderRemark")
    Observable<YunShlResult<List<OrderRemarkBean>>> addOrderRemark(@Body Object body);


    /**
     * 获取产品类列表
     * @return
     */
    @GET("api/v1/common/data/getProductTypes")
    Observable<YunShlResult<List<ProductGroupBean>>> getProductTypes();

    /**
     *
     * @param groupId 产品类id
     * @param templateId 产品模板id
     * @param supplierId 批发商id
     * @param buyerId 买家id
     * @param keyWord
     * @param currentPage
     * @param pageSize
     * @return
     */
    @GET("api/v1/shop/product/searchProductList")
    Observable<YunShlResult<ProductPageBean>> getProductList(@Query("product_type_id") Integer groupId,
                                                             @Query("product_template_id") Integer templateId,
                                                             @Query("supplier_id") Integer supplierId,
                                                             @Query("buyer_id") Integer buyerId,
                                                             @Query("keyword_") String keyWord,
                                                             @Query("currentPage") int currentPage,
                                                             @Query("showCount") int pageSize);

    @GET("/api/v1/mine/user/addressBookList")
    Observable<YunShlResult<PageDataBean<AddrbookBean>>> addressBookList(@Query("type") int type,
                                                                         @Query("currentPage") int currentPage);

    @POST("api/v2/buy/sms_points")
    Observable<YunShlResult<Object>> buySmsPoint(@Body Map<String,Object> params);

    @POST("api/v2/buy/dispatch_points")
    Observable<YunShlResult<Object>> buyDispatchPoint(@Body Map<String,Object> params);

    /**
     * 添加产品到购物车
     * @param params
     * @return
     */
    @POST("api/v1/shop/orders/addPersonalCartItems")
    Observable<YunShlResult<Object>> addProductToCart(@Body Object params);

    /**
     * 代他人添加产品到购物车
     * @param params
     * @return
     */
    @POST("api/v1/shop/orders/addBuyerCartItems")
    Observable<YunShlResult<Object>> addBuyerCartItems(@Body Object params);

    @PUT("api/v1/shop/orders/updateCartItemByProduct")
    Observable<YunShlResult<Object>> updateCart(@Body Object params);

    @GET("api/v1/shop/orders/getCartInfo")
    Observable<YunShlResult<List<CartBean>>> getCartInfo();

    /**
     * 获取通讯录列表
     * @return
     */
    @GET("api/v2/user/mobile_lists")
    Observable<YunShlResult<MobileListBean>> mobilList(@Query("page") int type,
                                                       @Query("per_page") int currentPage,
                                                        @Query("page_type") int page_type );

    /**
     * 通过id获取用户信息
     * @param user_id
     * @return
     */
    @GET("api/v2/user/{user_id}")
    Observable<YunShlResult<UserBean>> getUserInfo(@Path("user_id") long user_id);

    /**
     * 更新或者上传通讯录
     * @return
     */
    @PUT("api/v2/user/mobile_lists")
    Observable<YunShlResult<MobileListBean>> updateMobilList(@Body Map<String,List<String>> body);

    /**
     * 获取添加或者被添加的历史列表
     * @return
     */
    @GET("api/v2/invite/logs")
    Observable<YunShlResult<MobileListBean>>  addFriendsLogs();

    /**
     * 通过好友认证
     * @param body
     * @return
     */
    @PUT("api/v2/invite/logs")
    Observable<YunShlResult<MobileListBean>>  agreeAddFriendsLogs(@Body Map<String,Object> body);

    /**
     * 好友列表
     * @return
     */
    @GET("api/v2/user/friends")
    Observable<YunShlResult<MobileListBean>>  friends();

    @PUT("api/v1/shop/orders/updateCartItem")
    Observable<YunShlResult<Object>> updateCartItem(@Body Object object);

    @POST("api/v1/shop/orders/createOrder")
    Observable<YunShlResult<SingleOrderItem>> createOrder(@Body OrderCreateParams params);

    /**
     * 添加好友申请
     * @return
     */
    @POST("api/v2/invite/friend/{followed_id}")
    Observable<YunShlResult<Object>> addFriends(@Path("followed_id") String followed_id);

    @GET("api/v1/mine/orders/getById/{id_}")
    Observable<YunShlResult<OrderItemBean>> getOrderDetail(@Path("id_") int orderId);

    @GET("api/v1/shop/orders/getCartItemQuantity")
    Observable<YunShlResult<Integer>> getCartItemProductCount();

    @GET("api/v2/test/send/message?")
    Observable<YunShlResult<Object>> get(@Query("mobile") String mobile,
                                         @Query("to_mobile") String to_mobile);


    /**
     * 未读好友申请记录数量
     * @return
     */
    @GET("api/v2/invite/logs/un_read_count")
    Observable<YunShlResult<RecentMsgBean>> unReadCount();

    @POST("api/v2/user/mobile_lists")
    Observable<YunShlResult<Object>> invitefriends(@Body Map<String,String> params);

    /**
     * 拨打用户电话
     * @param user_id
     * @return
     */
    @GET("api/v2/user/{user_id}/call")
    Observable<YunShlResult<Object>> call(@Path("user_id") String user_id);


    /**
     * 获取区域工程商信息
     * @return
     */
    @GET("/api/v1/mine/product/getAreaEngineerInfo")
    Observable<YunShlResult<List<AreaBean>>> getAreaEngineerInfo();

    /**
     * 发布动态
     * @param dynamic
     * @return
     */
    @POST("/api/v1/social/businessCircle/saveDynamic")
    Observable<YunShlResult<Object>> saveDynamic(@Body SaveDynamic dynamic );


    /**
     * 上传图片或视频
     * @param body
     * @return
     */
    @POST("api/v2/time_line/pictures")
    Call<YunShlResult<BaseUrlBean>> pictures(@Body RequestBody body);

    @GET("/api/v1/base/company/getMyCompany")
    Observable<YunShlResult<CompanyBean>> getMyCompany();

    @GET("/api/v1/social/businessCircle/searchLatelyDynamicList")
    Observable<YunShlResult<List<DynamicBean>>> searchLatelyDynamicList(@Query("user_id") long id);

    /**
     * 添加动态评论
     * @param params
     * @return
     */
    @POST("api/v1/social/businessCircle/addReply")
    Observable<YunShlResult<List<CommentBean>>> addReply(@Body Map<String,Object> params);

    /**
     * 点赞或取消
     * @param params
     * @return
     */
    @POST("api/v1/social/businessCircle/addOrCancelLike")
    Observable<YunShlResult<List<ThumbUpBean>>> addOrCancelLike(@Body Map<String,Object> params);

    @GET("api/v1/social/businessCircle/searchAllList")
    Observable<YunShlResult<DynamicPageData>> searchAllDynamicList(@Query("showCount") int showCount,
                                                                   @Query("update_time_") Long time);

    /**
     * 获取指定
     * @param id
     * @param showCount
     * @param time
     * @return
     */
    @GET("api/v1/social/businessCircle/searchList")
    Observable<YunShlResult<DynamicPageData>> searchUserDynamicList(@Query("user_id") int id,
                                                                    @Query("showCount") int showCount,
                                                                    @Query("update_time_") Long time);

    /**
     * 删除评论
     * @param id
     * @return
     */
    @DELETE("api/v1/social/businessCircle/deleteReply/{reply_id}")
    Observable<YunShlResult<List<CommentBean>>> deleteComment(@Path("reply_id") int id);

    /**
     * 删除动态
     * @param id
     * @return
     */
    @DELETE("api/v1/social/businessCircle/deleteById/{id}")
    Observable<YunShlResult<Object>> deleteDynamic(@Path("id") int id);



    @GET("api/v1/social/businessCircle/hasNewDynamic")
    Observable<YunShlResult<Boolean>> hasNewDynamic(@Query("update_time_") int updateTime);

    /**
     * 获取公司列表
     * @param page
     * @param keyword_
     * @return
     */
    @GET("/api/v1/base/company/searchList")
    Observable<YunShlResult<PageDataBean<CompanyBean>>> searchCompanyList(@Query("currentPage") int page,
                                                                          @Query("keyword_") String keyword_);

    /**
     * 保存公司名称
     * @param edit
     * @return
     */
    @POST("/api/v1/base/company/saveCompanyName")
    Observable<YunShlResult<CompanyBean>> saveCompanyName(@Body CompanyBean edit);

    /**
     *保存公司基础信息
     * @param edit
     * @return
     */
    @POST("/api/v1/base/company/saveCompanyBase")
    Observable<YunShlResult<CompanyBean>> saveCompanyBase(@Body CompanyBean edit);

    /**
     *保存案例和发展历程
     * @param edit
     * @return
     */
    @POST("/api/v1/base/company/saveCompanyCaseAndCourse")
    Observable<YunShlResult<CompanyBean>> saveCompanyCaseAndCourse(@Body CompanyBean edit);

    /**
     *保存公司注册信息
     * @param edit
     * @return
     */
    @POST("/api/v1/base/company/saveCompanyRegister")
    Observable<YunShlResult<CompanyBean>> saveCompanyRegister(@Body CompanyBean edit);

    /**
     *保存技能并完成
     * @param edit
     * @return
     */
    @POST("/api/v1/base/company/saveCompanySkill")
    Observable<YunShlResult<CompanyBean>> saveCompanySkill(@Body CompanyBean edit);


    /**
     *保存/修改公司草稿
     * @param edit
     * @return
     */
    @POST("/api/v1/base/company/saveDrafts")
    Observable<YunShlResult<CompanyBean>> saveDrafts(@Body CompanyBean edit);

    /**
     *获取我的草稿公司新
     * @return
     */
    @GET("/api/v1/base/company/getMyDraftsCompany")
    Observable<YunShlResult<CompanyBean>> getMyDraftsCompany();

    @GET("/api/v1/base/company/joinCompany/{id_}")
    Observable<YunShlResult<CompanyBean>> joinCompany(@Path("id_") long id );

}
